#include <memory>
#include "UdpServer.hpp"
#include "Dict.hpp"

// 利用命令行参数
// ./udpserver port
int main(int argc,char* argv[])
{
    if(argc != 2)
    {
        std::cerr << "Usage: "<< argv[0] << " port" << std::endl;
        return 1;
    }

    uint16_t port = std::stoi(argv[1]);
    Dict dict;
    dict.LoadDict();
    std::unique_ptr<UdpServer> udp_server = std::make_unique<UdpServer>(port,[&dict](const std::string& buf,const InetAddr& client)->std::string{
        return dict.Translate(buf,client);
    });

    udp_server->Init();
    udp_server->Start();

    return 0;
}